package Singleton.singleton;


import Singleton.interfaces.Singleton;

/**
 * 性能低下的单例模式——同步锁造成的性能低下
 * 延迟加载lazy
 * @Author: pengzx
 * @Description:
 * @Date: 17:03 2017/9/11
 * @Modified by: 1.0
 */
public class LazySingleton extends Singleton {
    private static LazySingleton singleton;

    private LazySingleton()
    {
        say = "你好...懒汉模式！";
    }

    public static synchronized LazySingleton getInstance()
    {
        if (singleton == null) {
            singleton = new LazySingleton();
        }
        return singleton;
    }

    @Override
    public void say()
    {
        System.out.println(say);
    }
}
